package com.guit.apt;

import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.type.AnnotationType;
import com.sun.mirror.type.ArrayType;
import com.sun.mirror.type.ClassType;
import com.sun.mirror.type.DeclaredType;
import com.sun.mirror.type.EnumType;
import com.sun.mirror.type.InterfaceType;
import com.sun.mirror.type.PrimitiveType;
import com.sun.mirror.type.ReferenceType;
import com.sun.mirror.type.TypeMirror;
import com.sun.mirror.type.TypeVariable;
import com.sun.mirror.type.VoidType;
import com.sun.mirror.type.WildcardType;
import com.sun.mirror.util.TypeVisitor;

public class GuitTypeVisitor implements TypeVisitor {

  private boolean isClass;

  private boolean isInterface;

  private boolean isDeclared;

  private boolean isWildcard;

  private boolean isVoid;

  private TypeDeclaration decl;

  @Override
  public void visitAnnotationType(AnnotationType arg0) {
    decl = arg0.getDeclaration();
  }

  @Override
  public void visitArrayType(ArrayType arg0) {
  }

  @Override
  public void visitClassType(ClassType arg0) {
    ClassDeclaration decl = arg0.getDeclaration();
    if (decl != null) {
      setClass(true);
      this.decl = decl;
    }
  }

  @Override
  public void visitDeclaredType(DeclaredType arg0) {
    setDeclared(true);
    decl = arg0.getDeclaration();
  }

  @Override
  public void visitEnumType(EnumType arg0) {
    decl = arg0.getDeclaration();
  }

  @Override
  public void visitInterfaceType(InterfaceType arg0) {
    setInterface(true);
    decl = arg0.getDeclaration();
  }

  @Override
  public void visitPrimitiveType(PrimitiveType arg0) {
  }

  @Override
  public void visitReferenceType(ReferenceType arg0) {
  }

  @Override
  public void visitTypeMirror(TypeMirror arg0) {
  }

  @Override
  public void visitTypeVariable(TypeVariable arg0) {
  }

  @Override
  public void visitVoidType(VoidType arg0) {
    isVoid = true;
  }

  @Override
  public void visitWildcardType(WildcardType arg0) {
    setWildcard(true);
  }

  public void setClass(boolean isClass) {
    this.isClass = isClass;
  }

  public boolean isClass() {
    return isClass;
  }

  public void setInterface(boolean isInterface) {
    this.isInterface = isInterface;
  }

  public boolean isInterface() {
    return isInterface;
  }

  public void setDeclared(boolean isDeclared) {
    this.isDeclared = isDeclared;
  }

  public boolean isDeclared() {
    return isDeclared;
  }

  public void setWildcard(boolean isWildcard) {
    this.isWildcard = isWildcard;
  }

  public boolean isWildcard() {
    return isWildcard;
  }

  public boolean isVoid() {
    return isVoid;
  }

  public TypeDeclaration getDeclaration() {
    return decl;
  }
}
